﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Navigation;

namespace Techdays2013
{
    public class AssociationUriMapper : UriMapperBase
    {
        public override Uri MapUri(Uri uri)
        {
            // on decode la chaine pour recupérer le protocole original
            string uriString = HttpUtility.UrlDecode(uri.ToString());
            
            const string uriTechdays = "/Protocol?encodedLaunchUri=techdays2013:///";

            if (uriString.StartsWith(uriTechdays))
            {
                // On recupère tout se qui suit le ? (le ? étant inclus) 
                string query = uriString.Substring(uriTechdays.Length);

                return new Uri("/SpeechRecognitionPage.xaml" + query, UriKind.Relative);
            }

            return uri;
        }
    }
}
